﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Net.DnsToolkit.Serializer;
using System.Net.DnsToolkit.Packet;
using System.Net.DnsToolkit.Packet.Busy;

namespace System.Net.DnsToolkit.TestUnit.Helper {
    [TestFixture]
    public class MessageHelperTest {

        [Test]
        public void Test1() {

            MessageHelper.DeepCompare(
                new Message(),
                new Message());


        }

        [Test]
        [ExpectedException]
        public void Test2() {

            MessageHelper.DeepCompare(
                new Message(),
                new Message() {
                    Header = new Header() {
                        Truncation = true
                    }
                }
                );



        }

        [Test]
        [ExpectedException]
        public void Test3() {

            MessageHelper.DeepCompare(
                new Message(),
                new Message() {
                    Additionals = {
                        new RR() {
                            Ttl = 100
                        }
                    }
                }
                );


        }

        [Test]
        public void Test4() {

            MessageHelper.DeepCompare(
                new Message() {
                    Additionals = {
                        new RR() {
                            Ttl = 100
                        }
                    }
                },
                new Message() {
                    Additionals = {
                        new RR() {
                            Ttl = 100
                        }
                    }
                }
                );



        }
        [Test]
        [ExpectedException]
        public void Test5() {

            MessageHelper.DeepCompare(
                new Message() {
                    Additionals = {
                        new RR() {
                            Ttl = 3
                        }
                    }
                },
                new Message() {
                    Additionals = {
                        new RR() {
                            Ttl = 100
                        }
                    }
                }
                );


        }

        #region Header


        [Test]
        public void TestHeaderNull() {

            MessageHelper.DeepCompare((Header)null, (Header)null);

        }

        [Test]
        public void TestHeader1() {

            MessageHelper.DeepCompare(
                new Header(),
                new Header());



        }

        [Test]
        [ExpectedException]
        public void TestHeader2() {

            MessageHelper.DeepCompare(
                new Header(),
                new Header() {
                    AnswerAuthenticated = true
                });


        }

        [Test]
        [ExpectedException]
        public void TestHeader3() {

            MessageHelper.DeepCompare(
                new Header(),
                new Header() {
                    Truncation = true
                });


        }

        [Test]
        [ExpectedException]
        public void TestHeader5() {

            MessageHelper.DeepCompare(new Header(), null);


        }

        [Test]
        [ExpectedException]
        public void TestHeader6() {

            MessageHelper.DeepCompare(null, new Header());

        }

        [Test]
        [ExpectedException]
        public void TestHeader7() {

            MessageHelper.DeepCompare(
                new Header(),
                new Header() {
                    Truncation = true
                });

        }


        #endregion

    }
}
